package com.ricchieri.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.springframework.cache.annotation.Cacheable;

import com.ricchieri.dao.interf.ICancelationTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.CancelationType;

public class CancelationTypeDao extends GenericDao implements ICancelationTypeDao {
	private static final long serialVersionUID = -9147567242758023374L;

	@SuppressWarnings("unchecked")
	@Override
	@Cacheable(value="cancelationType")
	public List<CancelationType> getAllCancelationType(BasicFilter cancelationTypeFilter) {
			
		Criteria criteria = criteriaAllCancelation(cancelationTypeFilter);
		
		return criteria.list();
	}

	@Override
	public CancelationType getCancelationTypeById(BasicFilter cancelationTypeFilter) {
		Criteria criteria = criteriaAllCancelation(cancelationTypeFilter);
		
		return (CancelationType) criteria.list().get(0);
	}

		
	private Criteria criteriaAllCancelation(BasicFilter filter) {
		return super.criteriaAllBasic(filter, CancelationType.class);
	}	
	
	@Override
	protected String getTableName() {
		return "cancelation";
	}
}
